<?php
namespace Client\Table;

use Zend\Db\Sql\Select;
use Zend\Db\Sql\Where;

class MaterialCategoryTable extends CommonTable
{
    protected $table = 'hy_material_category';
    protected $id = 'material_category_id';
    
    
    public function fetchAll() {
    	$select = new Select(array('c' => $this->getTable()));
    	$rowset = $this->selectWith($select);
    	$rowList = $rowset->toArray();
    	return $rowList;
    
    }
    /**
     * 查询商品原料
     * @param number $limit
     * @param string $paginated
     */
    public function getMaterialByProductID($product_id) {
        $select = new Select($this->getTable());
        $select->columns( array(
            "material_id","material_code","material_name","product_id",
        ));
        $select->where(array('product_id' => $product_id));
        $rowset = $this->selectWith($select);
        $result = $rowset->toArray();
        return $result;
    }
    
    public function getCategoryMaterials($categoryIds){
    	
    	$select = new Select($this->getTable());
    	$select->columns( array(
			'material_id', 'material_category_id', 'product_id', 'material_code', 'material_name', 'original', 'description', 'workflow', 'feature', 'contact', 'create_time', 'update_time'
    	));
    	$select->where(array('material_category_id' => $categoryIds));
    	$rowset_ranking = $this->selectWith($select);
    	$row = $rowset_ranking->toArray();
    	return $row;
    	
    }
    
    
}